<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:constants="http://www.tuanzi.com/constants/tags">

<p:dialog header="编辑二级项" widgetVar="itemOptionDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false" width="50%">
    <p:outputPanel id="itemOptionDetail">

        <div class="ui-fluid" style="padding-top: 10px;">
            <div class="ui-g">
                <div class="ui-g-12">
                    <!-- 列表 -->
                    <div class="cad">
                        <p:growl id="itemOptionMsgs" showDetail="true"/>

                        <p:dataTable id="itemOptionListDataTable"
                                     widgetVar="itemOptionDataTable"
                                     style="width: 100%"
                                     var="item"
                                     value="#{activityItemListBean.modelItemOptionList}"
                                     scrollable="true"
                                     scrollWidth="100%"
                                     editable="true">

                            <f:facet name="header">
                                所属一级项ID：<h:outputText value="#{activityItemListBean.currentItem.id}" />
                            </f:facet>

                            <p:ajax event="rowEdit" listener="#{activityItemListBean.onItemOptionRowEdit}" update="itemOptionListDataTable"/>
                            <p:ajax event="rowEditCancel" listener="#{activityItemListBean.onItemOptionRowCancel}" update="itemOptionListDataTable"/>

                            <p:column headerText="二级项ID">
                                <h:outputText value="#{item.id}" />
                            </p:column>
                            <p:column headerText="二级项名称">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <p:selectOneMenu value="#{item.optionBasisId}" disabled="true">
                                            <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                            <f:selectItems value="#{activityItemListBean.modelItemOptionBasisList}" var="model"
                                                           itemLabel="#{model.optionValue}" itemValue="#{model.id}"/>
                                        </p:selectOneMenu>
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:selectOneMenu value="#{item.optionBasisId}">
                                            <f:selectItems value="#{activityItemListBean.modelItemOptionBasisList}" var="model"
                                                           itemLabel="#{model.optionValue}" itemValue="#{model.id}"/>
                                        </p:selectOneMenu>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>

                            <p:column headerText="是否显示子项">
                                <p:cellEditor>
                                    <f:facet name="output"><h:outputText value="#{item.showSon==1?'是':'否'}"/></f:facet>
                                    <f:facet name="input">
                                        <p:selectOneMenu value="#{item.showSon}">
                                            <f:selectItem itemLabel="是" itemValue="1"/>
                                            <f:selectItem itemLabel="否" itemValue="0"/>
                                        </p:selectOneMenu>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>

                            <p:column headerText="排序号">
                                <p:cellEditor>
                                    <f:facet name="output"><h:outputText value="#{item.sort}"/></f:facet>
                                    <f:facet name="input"><p:inputText value="#{item.sort}"  style="width:100%" label="排序号"/></f:facet>
                                </p:cellEditor>
                            </p:column>

                            <p:column style="width:32px">
                                <p:rowEditor/>
                            </p:column>
                        </p:dataTable>
                    </div>
                    <!-- 列表 -->
                </div>

                <div class="ui-g-12">
                    <p:commandButton value="新增行" styleClass="ui-priority-primary" process="@this"
                                     update=":optionForm:itemOptionMsgs"
                                     action="#{activityItemListBean.onItemOptionAddNew(activityItemListBean.currentItem.id)}"
                                     oncomplete="PF('itemOptionDataTable').addRow();"/>
                </div>
            </div>
        </div>
    </p:outputPanel>
</p:dialog>

</html>